<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
             label-width="68px" style="display: flex; flex-wrap: nowrap;">
      <el-form-item label="上传客户" prop="F0301" style="display: flex; flex-wrap: nowrap;">
        <el-input
          style="width: 14vw"
          v-model="queryParams.F0301"
          placeholder="请输入上传客户"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="执行状态" prop="F0906" style="display: flex; flex-wrap: nowrap;">
        <el-select v-model="queryParams.F0906" placeholder="请选择执行状态" clearable>
          <el-option
            style="width: 14vw"
            v-for="dict in dict.type.zsk_execution_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item style="margin: 0 0 0 30vw;">
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          style="background-color: black; color: white;"
          @click="download"
          >批量下载</el-button>
          <!-- v-hasPermi="['t03:t03:export']" -->
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="T09List" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="文件编号" align="center" prop="f0901" />
      <el-table-column label="上传客户" align="center" prop="f0302" />
      <el-table-column label="文件名称" align="center" prop="f0902" />
      <el-table-column label="文件格式" align="center" prop="f0904" />
      <el-table-column label="上传人" align="center" prop="f1804" />
      <el-table-column label="用户上传时间" align="center" prop="f0905" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.f0905, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="执行状态" align="center" prop="f0906">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.zsk_execution_status" :value="scope.row.f0906"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-if="scope.row.f0906===1"
            size="mini"
            type="text"
            @click="submitForm(scope.row)"
            v-hasPermi="['T09:T09:edit']"
          >已处理</el-button>
          <el-button
            size="mini"
            type="text"
            @click="download(scope.row)"
            v-hasPermi="['T09:T09:remove']"
          >下载文档</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listT09, updateT09 } from "@/api/T09/T09";

export default {
  name: "T09",
  dicts: ['zsk_execution_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 知识库表格数据
      T09List: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        F0301: null,
        F0906: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询知识库列表 */
    getList() {
      this.loading = true;
      listT09(this.queryParams).then(response => {
        this.T09List = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.f0901)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    submitForm(row) {
      const a = row.f0901;
      const b = 0;
      updateT09({f0901:a,f0906:b}).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.open = false;
        this.getList();
      })
    },
    //下载接口
    download(row){
      const ids = row.f0901 || this.ids;
      console.log(ids)
      alert(ids)
    },
  }
};
</script>
<style>
.el-tag-common-red {
    background-color: #ffebee; /* 浅红色背景 */
    border-color: #d32f2f; /* 深红色边框 */
    color: #b71c1c; /* 深红色字体 */
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    font-size: 12px;
    line-height: 1;
    border-width: 1px;
    border-style: solid;
    border-radius: 4px;
    box-sizing: border-box;
    white-space: nowrap;
}
.el-tag-red {
    /* 重写.el-tag-common的样式以使用红色主题 */
    background-color: #ffebee; /* 浅红色背景 */
    border-color: #d32f2f; /* 深红色边框 */
    color: #b71c1c; /* 深红色字体 */
    /* 如果需要特别指定.el-tag-green独有的样式，可以在这里添加 */
}
.el-tag-common-green {
    background-color: #E8FFEA; /* 浅绿色背景 */
    border-color: #98e69e; /* 深一些的绿色边框 */
    color: #66ffcc; /* 更亮的绿色字体 */
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    font-size: 12px;
    line-height: 1;
    border-width: 1px;
    border-style: solid;
    border-radius: 4px;
    box-sizing: border-box;
    white-space: nowrap;
}
.el-tag-green {
    /* 假设您希望.el-tag-green与.el-tag-common完全一致，或者您可以指定不同的绿色 */
    background-color: #e0f2f1; /* 浅绿色背景 */
    border-color: #b2d7d2; /* 深一些的绿色边框 */
    color: #4fdc4f; /* 更亮的绿色字体 */
}
</style>
